package com.example.sixteen.jt.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class PreferenceUtils {

    private static class PreferenceTypeClass {
        private static PreferenceUtils instance = new PreferenceUtils();
    }

    public static PreferenceUtils getInstance() {
        return PreferenceTypeClass.instance;
    }

    private Context context;
    private SharedPreferences sharedPreferences;

    public void init(Context context) {
        this.context = context;
        this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    }

    public int getTimes() {
        return sharedPreferences.getInt("times", 2);
    }

    public void setTimes(int times) {
        sharedPreferences.edit().putInt("times", times).commit();
    }

    public String getIp() {
        return sharedPreferences.getString("ip", "192.168.2.200");
    }

    public void setIp(String ip) {
        sharedPreferences.edit().putString("ip", ip).commit();
    }
}
